package com.rupertjones.globalcron.web.service;

import com.rupertjones.globalcron.domain.User;
import com.rupertjones.globalcron.domain.UserDAO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>&copy Rupert Jones 2012</p>
 *
 * @author rup
 */
@Service
public class UserService {

    @Autowired
    private UserDAO userDAO;

    public User findUser(String username) {
        return userDAO.findByUsername(username);
    }

    public void saveWithPassword(User user, String password) {
        user.setPassword(userDAO.hash(password));
        userDAO.upsert(user);
    }
}
